//
//  CallCenterController.swift
//  HHSwift
//
//  Created by 华宏 on 2020/9/8.
//  Copyright © 2020 huahong. All rights reserved.
//

import UIKit
import CoreTelephony

class CallCenterController: BaseViewController {

    let callCenter = CTCallCenter()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = "电话监听"
        
        monitorCall()
    }
    

    func monitorCall() {
        
        self.callCenter.callEventHandler = { (call:CTCall) in
            
            switch call.callState {
            case CTCallStateIncoming:
                print("来电")
            case CTCallStateConnected:
                print("已接通")
            case CTCallStateDialing:
                print("拨打中")
            case CTCallStateDisconnected:
                print("已断开")
            default: break
                
            }
        }
    }
    

}
